//
//  WYReleaseView.m
//  Boss
//
//  Created by admin on 2018/6/4.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYReleaseView.h"
@interface WYReleaseView()
@property (strong, nonatomic) IBOutlet UIImageView *redImageView;
@property (strong, nonatomic) IBOutlet UIImageView *cityImageView;
@property (strong, nonatomic) IBOutlet UIImageView *backImageView;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *bottomHeight;
@property (strong, nonatomic) IBOutlet UIView *bottomView;

@end
@implementation WYReleaseView
-(void)awakeFromNib
{
    
    [super awakeFromNib];
    //设置背景图片    
    UITapGestureRecognizer *ges = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickRedImageView)];
    UITapGestureRecognizer *ges1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickCityImageView)];
    [self.redImageView addGestureRecognizer:ges];
    [self.cityImageView addGestureRecognizer:ges1];
    self.userInteractionEnabled = YES;
    UITapGestureRecognizer *ges2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickView)];
    [self addGestureRecognizer:ges2];
    if (kDevice_Is_iPhoneX) {
        self.bottomHeight.constant = 83;
//        self.buttonTopHeight.constant = -self.bottomHeight.constant*0.2;
//        self.centerBtn.center = CGPointMake(self.width * 0.5-10, self.height * 0.2);
    }else{
       self.bottomHeight.constant = 50;
//        self.buttonTopHeight.constant = -self.bottomHeight.constant*0.3;
//        self.centerBtn.center = CGPointMake(self.width * 0.5-10, self.height * 0.3);
    }
    [self addBtn];
}

-(void)addBtn
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//    [button setImage:[UIImage imageNamed:@"icon_tabbar_add_normal"] forState:UIControlStateNormal];
    
//    [button setImage:[UIImage imageNamed:@"发布"] forState:UIControlStateNormal];
   [button setImage:[UIImage imageNamed:@"icon_tabbar_add_select"] forState:UIControlStateNormal];
    [button setTitle:@"发布" forState:UIControlStateNormal];
    button.titleEdgeInsets = UIEdgeInsetsMake(34+20, -31, 0, 0);
    button.imageEdgeInsets = UIEdgeInsetsMake(-11.5, 20, 0, 0);
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
    [button setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:10];
    [self.bottomView addSubview:button];
    [button addTarget:self action:@selector(clickView) forControlEvents:UIControlEventTouchUpInside];
    if (kDevice_Is_iPhoneX) {
        CGFloat height = 88;
//        button.center = CGPointMake(self.width * 0.5-10, self.height * 0.2);
         button.frame = CGRectMake(kScreenWidth/2.0-36-10, -height*0.2-2, 72, 72);
    }else{
        CGFloat height = 49;
//        button.center = CGPointMake(self.width * 0.5-10, self.height * 0.3);
        button.frame = CGRectMake(kScreenWidth/2.0-36-10, -height*0.3-6, 72, 72);
    }
    
}



-(void)setImage:(UIImage *)image
{
    _image = image;
    
    self.backImageView.image = image;
    //   设置UIVisualEffectView
    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    UIVisualEffectView *visualView = [[UIVisualEffectView alloc]initWithEffect:blurEffect];
    visualView.alpha = 0.98;
    visualView.frame = self.bounds;
    [self.backImageView addSubview:visualView];
}


-(void)clickView
{
    if ([self.delegate respondsToSelector:@selector(clickBackView)]) {
        [self.delegate clickBackView];
    }
    [self removeFromSuperview];
}

-(void)clickRedImageView
{
    if ([self.delegate respondsToSelector:@selector(clickRedView)]) {
        [self.delegate clickRedView];
    }
    
    NSLog(@"123321");
}

-(void)clickCityImageView
{
    if ([self.delegate respondsToSelector:@selector(clickCityView)]) {
        [self.delegate clickCityView];
    }
      NSLog(@"456564");
}

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self createSubView];
    }
    return self;
    
    
}
-(void)createSubView
{
    
    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    UIVisualEffectView *visualView = [[UIVisualEffectView alloc]initWithEffect:blurEffect];
    visualView.frame = self.bounds;
    visualView.alpha = 0.98;
    [self addSubview:visualView];
    
    
    
    
    
    
    
    
    
}












@end
